const Mock = require("mockjs")
const Random = Mock.Random

let Result = {
    code:200,
    token:null,
    msg:"success",
    data:""
}

const userDate=[
    {
        text:"敲代码",
        status:false
    },{
        text:"写笔记",
        status:false
    },{
        text:"吃饭",
        status:false
    },{
        text:"打游戏",
        status:false
    }
]

Mock.mock('/test','post',(options)=>{
    console.log(options)
    const user = JSON.parse(options.body)
    if(user.username==='admin')
        Result.data={
            list:userDate
        }
    else{
        Result.code=400
    }
    return Result
})

Mock.mock('/login','post',(options)=>{
    const user = JSON.parse(options.body)
    if(user.username ==='admin' && user.password==="admin" ){
        Result.code = 200
        Result.token = Random.string(32)
        Result.data = {
            username : 'admin'
        }
    }
    else
        Result.code = 401
        Result.msg = '请检查你的账号密码'
    return Result
})